<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="./jquery-3.6.0.js"></script>
    <link rel="stylesheet" href="./bootstrap.css">
    <title>Document</title>
    <style>
      /* body{
        background-image: url(./11.jpg);
        background-position-y: -100px;
      } */
        .xuxu img{
            width: 1000px;
            height: 1000px;
        }
        .xu11{
          position: absolute;
          left: 600px;
          top: 400px;
        }
    </style>
</head>
<body>
    <ol class="breadcrumb">
        <li><a href="#">详情页</a></li>
        <li><a href="#">首页</a></li> 
      </ol>
      <div class="container">
        <div class="media"> 
        </div>
      </div> 
    <script>
        var id=sessionStorage.getItem('id')
        console.log(id)
        $.ajax({
            url:'https://api.it120.cc/conner/shop/goods/detail',
            type:'get',
            data:{
                id
            }              
        }).then(res=>{
            if(res.code==0){
                console.log(res)
                var i=res.data
               
                var str=''
                str+=`
                <div class="media-left">
          <a href="#">
            <img class="media-object" src="${i.basicInfo.pic}" alt="...">
          </a>
        </div>
        <div class="media-body">
          <h4 class="media-heading">${i.basicInfo.name}</h4>
          价格：${i.basicInfo.originalPrice}
        </div>
        <button class="xu11">加入收藏页</button>
        <ol class="breadcrumb">
        <li><a href="#">详情图</a></li>
        
        
      </ol>
        <div class="xuxu">
            <img src="${i.pics2[0]}" alt="..." >
            
        </div>  
                `
            }
            document.querySelector('.media').innerHTML=str
            
        })
        $('.container').on('click','.xu11',function(){
          $.ajax({
          type:'post',
          url:'https://api.it120.cc/conner/shop/goods/fav/add',
          data:{
            type:0,
            token:localStorage.getItem('token'),
            goodsId:id

          }
          }).then(res=>{
            console.log(res)
            if(res.code==0){
            var bool=  confirm('加入购物成功，是否前往购物车页')
            bool&&(location.href='./shouc.html')

            }else{
              location.href='./login.html'
            }
          })

        })

        
      
    </script>
</body>
</html>